﻿using AZai.Model;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace AZai.ViewModel
{
    public class BiddingViewModel : TabBase
    {
        public BiddingViewModel() 
        {
            for (int i = 0; i < 6; i++)
            {
                List.Add(new TempModel() { 
                    Name=i+ "AduSkin",
                    Remark="追求极致，永臻完美"
                });
            }
            TreeData = new ObservableCollection<TreeModel>() {
                new TreeModel(){
                    Name="根节点",
                    TreeType=TreeType.Root,
                    Children=new List<TreeModel>()
                    {
                        new TreeModel(){
                            Name="(01)呵呵哒",
                            TreeType=TreeType.Folder,
                            Children=new List<TreeModel>()
                            {
                                new TreeModel(){
                                    Name="666",
                                    TreeType=TreeType.Item,
                                    IsPause=true
                                },
                                new TreeModel(){
                                    Name="233",
                                    TreeType=TreeType.Item
                                }
                            }
                        },
                        new TreeModel(){
                            Name="(02)嘿嘿",
                            TreeType=TreeType.Folder,
                            Children=new List<TreeModel>()
                            {
                                new TreeModel(){
                                    Name="555",
                                    TreeType=TreeType.Item,
                                    IsPause=true
                                },
                                new TreeModel(){
                                    Name="3821",
                                    TreeType=TreeType.Item
                                }
                            }
                        }
                    }
                }
            };
        }

        private ObservableCollection<TempModel> _List = new ObservableCollection<TempModel>();
        /// <summary>
        /// 属性.
        /// </summary>
        public ObservableCollection<TempModel> List
        {
            get { return _List; }
            set { Set(ref _List, value); }
        }

        private ObservableCollection<TreeModel> _TreeData = new ObservableCollection<TreeModel>();
        /// <summary>
        /// 属性.
        /// </summary>
        public ObservableCollection<TreeModel> TreeData
        {
            get { return _TreeData; }
            set { Set(ref _TreeData, value); }
        }


        private string _SearchLength= "已输入0个关键字";
        /// <summary>
        /// 属性.
        /// </summary>
        public string SearchLength
        {
            get { return _SearchLength; }
            set { Set(ref _SearchLength, value); }
        }

        private string _SearchKey;
        /// <summary>
        /// 属性.
        /// </summary>
        public string SearchKey
        {
            get { return _SearchKey; }
            set { 
                Set(ref _SearchKey, value);
                SearchLength = $"已输入{value.Length}个关键字";
            }
        }

        private bool _IsOpenSearch;
        /// <summary>
        /// 属性.
        /// </summary>
        public bool IsOpenSearch
        {
            get { return _IsOpenSearch; }
            set { Set(ref _IsOpenSearch, value); }
        }

        /// <summary>
        /// 命令Command
        /// </summary>
        public ICommand OpenMenu => new RelayCommand<string>((e) =>
        {
            switch (e)
            {
                case "搜索面板":
                    IsOpenSearch = true;
                    break;
                case "清空搜索":
                    SearchKey = "";
                    break;
                default:
                    break;
            }
        });
    }
}
